<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" href="docgen-resources/docgen.css" type="text/css">
  <meta name="generator" content="FreeMarker Docgen (DocBook 5)">
  <title>
    FreeMarker Manual - Built-ins for nodes (for XML)
  </title>
    <script type="text/javascript" src="docgen-resources/jquery.js"></script>
    <script type="text/javascript" src="docgen-resources/linktargetmarker.js"></script>
</head>
<body>

    <div class="navigation">
    <div class="breadcrumb">
<span class="breadcrumb">        You are here:
          <a href="index.html">Book</a>
            <b>></b>
          <a href="ref.html">Reference</a>
            <b>></b>
          <a href="ref_builtins.html">Built-in Reference</a>
            <b>></b>
          Built-ins for nodes (for XML)
</span>    </div>
    <div class="bookmarks">
<span class="bookmarks">Bookmarks:
<a href="alphaidx.html">Alpha. index</a>, <a href="gloss.html">Glossary</a>, <a href="dgui_template_exp.html#exp_cheatsheet">Expressions</a>, <a href="ref_builtins_alphaidx.html">?builtins</a>, <a href="ref_directive_alphaidx.html">#directives</a>, <a href="ref_specvar.html">.spec_vars</a>, <a href="app_faq.html">FAQ</a>, <a href="api/index.html">API</a>, <a href="../index.html">Home</a></span>    </div>
    <div class="pagers">
      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
<div class="pagerButton"><a href="ref_builtins_expert.html"><span class="hideA">Next page: </span>Seldom used and expert built-ins</a></div><div class="pagerButton"><a href="ref_builtins_hash.html">Previous page</a></div><div class="pagerButton"><a href="ref_builtins.html">Parent page</a></div><div class="pagerButton"><a href="index.html">Contents</a></div>      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
    </div>
    </div>

<div id="mainContent">

  
  
  
  
  <h1 class="rank_section1"
        id="pageTopTitle">
<a name="ref_builtins_node"></a>Built-ins for nodes (for XML)  </h1>
    
    <div class="toc">
      <p>
        <b>
            Page Contents
        </b>
      </p>
      
  <ul class="noMargin">
      <li style="padding-bottom: 0.5em"><i><a href="#docgen_afterTheTOC">Intro.</a></i></li>
      <li>
        <a href="#ref_builtin_children">children</a>
      </li>
      <li>
        <a href="#ref_builtin_parent">parent</a>
      </li>
      <li>
        <a href="#ref_builtin_root">root</a>
      </li>
      <li>
        <a href="#ref_builtin_ancestors">ancestors</a>
      </li>
      <li>
        <a href="#ref_builtin_node_name">node_name</a>
      </li>
      <li>
        <a href="#ref_builtin_node_type">node_type</a>
      </li>
      <li>
        <a href="#ref_builtin_node_namespace">node_namespace</a>
      </li>
  </ul>
    </div>
    <a name="docgen_afterTheTOC"></a>
    
<p>Note that the variables returned by these built-ins are
        generated by the node variable implementation it is used with. This
        means that the returned variables can have extra features in
        additional to what it stated here, for example, with the <a href="xgui_expose_dom.html">XML DOM nodes</a> the sequence retuned by
        the <tt style="color: #A03D10">children</tt> built-in also can be used as hash and
        maybe as string, as it is described in the <a href="xgui.html">part
        about XML processing</a>.</p>
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="ref_builtin_children"></a>children  </h2>


          

          <p>A sequence that contains all of this node's child nodes (i.e.
          immediate descendant nodes).</p>

          <p>XML: This is almost the same as special hash key
          <tt style="color: #A03D10">*</tt>, except that it returns all nodes, not only
          elements. So the possible children are element nodes, text nodes,
          comment nodes, processing instruction nodes, etc. but
          <i>not</i> attribute nodes. Attribute nodes are
          excluded from the sequence.</p>
        
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="ref_builtin_parent"></a>parent  </h2>


          

          <p>The node that is this node's immediate parent in the node
          tree. The root node has no parent node, so for the root node, the
          expression
          <tt style="color: #A03D10"><i style="color: #DD4400">node</i>?parent??</tt>
          evaluates to <tt style="color: #A03D10">false</tt>.</p>

          <p>XML: Note that the value returned by this built-in is also a
          sequence (same as the result of XPath expression
          <tt style="color: #A03D10">..</tt>, when you write
          <tt style="color: #A03D10">someNode[&quot;..&quot;]</tt>). Also note that for attribute
          nodes, it returns the element the attribute belongs to, despite that
          attribute nodes are not counted as children of the element.</p>
        
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="ref_builtin_root"></a>root  </h2>


          

          <p>The node that is the root of the tree of nodes to which this
          node belongs.</p>

          <p>XML: According to W3C, the root of an XML document is not the
          topmost element node, but the document itself, which is the parent
          of the topmost element. For example, if you want to get the topmost
          <i>element</i> of the XML (the so called ``document
          element''; do not mix it with the ``document''), which is called
          <tt style="color: #A03D10">foo</tt>, then you have to write
          <tt style="color: #A03D10">someNode?root.foo</tt>. If you write just
          <tt style="color: #A03D10">someNode?root</tt>, then you get the document itself,
          and not the document element.</p>
        
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="ref_builtin_ancestors"></a>ancestors  </h2>


          

          <p>A sequence that contains all the node's ancestors, starting
          with the immediate parent and ending with the root node. The result
          of this built-in is also a method, by which you can filter the
          result with the <a href="gloss.html#gloss.fullQualifiedName">full-qualified name</a> of the
          node. For example as <tt style="color: #A03D10">node?ancestors(&quot;section&quot;)</tt> to
          get the sequence of all ancestors with name
          <tt style="color: #A03D10">section</tt>.</p>
        
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="ref_builtin_node_name"></a>node_name  </h2>


          

          <p>Returns the string that is used to determine what user-defined
          directive to invoke to handle this node when it is ``visited''. See:
          the <a href="ref_directive_visit.html#ref.directive.visit">visit</a> and <a href="ref_directive_visit.html#ref.directive.recurse">recurse</a> directives.</p>

          <p>XML: If the node is an element or attribute, then the string
          will be the local (prefix free) name of the element or attribute.
          Otherwise the name usually starts with <tt style="color: #A03D10">@</tt> followed
          by the node type. See <a href="xgui_imperative_formal.html#misc.xguiTable">this
          table</a>. Note that this node name is not the same as the node
          name returned in the DOM API; the goal of FreeMarker node names is
          to give the name of the used-defined directive that will process the
          node.</p>
        
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="ref_builtin_node_type"></a>node_type  </h2>


          

          <p>A string that describes the type of node this is. FreeMarker
          does not define the exact meaning of node type; it depends on what
          your variables are modeling. It's possible that a node doesn't
          support node type at all. In this case, the built-in evaluates to an
          undefined value, so you can't use the returned value. (You can still
          check if a node supports the type property with
          <tt style="color: #A03D10"><i style="color: #DD4400">node</i>?node_type??</tt>.)</p>

          <p>XML: The possible values are: <tt style="color: #A03D10">&quot;attribute&quot;</tt>,
          <tt style="color: #A03D10">&quot;text&quot;</tt>, <tt style="color: #A03D10">&quot;comment&quot;</tt>,
          <tt style="color: #A03D10">&quot;document_fragment&quot;</tt>,
          <tt style="color: #A03D10">&quot;document&quot;</tt>, <tt style="color: #A03D10">&quot;document_type&quot;</tt>,
          <tt style="color: #A03D10">&quot;element&quot;</tt>, <tt style="color: #A03D10">&quot;entity&quot;</tt>,
          <tt style="color: #A03D10">&quot;entity_reference&quot;</tt>,
          <tt style="color: #A03D10">&quot;notation&quot;</tt>, <tt style="color: #A03D10">&quot;pi&quot;</tt>. Note that a
          there is no <tt style="color: #A03D10">&quot;cdata&quot;</tt> type, because CDATA is
          considered as plain text node.</p>
        
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="ref_builtin_node_namespace"></a>node_namespace  </h2>


          

          <p>Returns the namespace string of the node. FreeMarker does not
          define the exact meaning of node namespace; it depends on what your
          node variables are modeling. It's possible that a node doesn't have
          any node namespace defined. In this case, the built-in should
          evaluate to undefined variable (i.e.
          <tt style="color: #A03D10">node?<i style="color: #DD4400">node_namespace</i>??</tt>
          is <tt style="color: #A03D10">false</tt>), so you can't use the returned
          value.</p>

          <p>XML: In the case of XML, it's the XML namespace URI (such as
          <tt style="color: #A03D10">&quot;http://www.w3.org/1999/xhtml&quot;</tt>). If an element or
          attribute node does not use XML namespace, then this built-in
          evaluates to an empty string. For other XML nodes this built-in
          always return undefined variable.</p>
          
</div>

    <div class="navigation">
    <div class="pagers">
      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
<div class="pagerButton"><a href="ref_builtins_expert.html"><span class="hideA">Next page: </span>Seldom used and expert built-ins</a></div><div class="pagerButton"><a href="ref_builtins_hash.html">Previous page</a></div><div class="pagerButton"><a href="ref_builtins.html">Parent page</a></div><div class="pagerButton"><a href="index.html">Contents</a></div>      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
    </div>
    <div class="breadcrumb">
<span class="breadcrumb">        You are here:
          <a href="index.html">Book</a>
            <b>></b>
          <a href="ref.html">Reference</a>
            <b>></b>
          <a href="ref_builtins.html">Built-in Reference</a>
            <b>></b>
          Built-ins for nodes (for XML)
</span>    </div>
    </div>

<table border=0 cellspacing=0 cellpadding=0 width="100%">
    <tr>
      <td colspan=2><img src="docgen-resources/img/none.gif" width=1 height=8 alt=""></td>
    <tr>
      <td align="left" valign="top"><span class="smallFooter">
            FreeMarker Manual -- For FreeMarker 2.3.20
            <br>
          HTML generated: 2013-06-27 20:54:33 GMT
      </span></td>
      <td align="right" valign="top"><span class="smallFooter">
          <a href="http://www.xmlmind.com/xmleditor/">
            <img src="docgen-resources/img/xxe.gif" alt="Edited with XMLMind XML Editor">
          </a>
      </span></td>
    </tr>
</table>
  <!-- Put pre-loaded images here: -->
  <div style="display: none">
    <img src="docgen-resources/img/linktargetmarker.gif" alt="Here!" />
  </div>
</body>
</html>

